package com.tedu.api.io;

import org.junit.Test;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.RandomAccessFile;

public class 匿名内部类重写FilterAPI {
    public static void main(String[] args) throws IOException {
        //主方法：./ 路径指定根级
        //1.创建File文件类 ： 获取当前API 文件夹 路径：./
        File ff = new File("." + File.separator + "API");
        System.out.println(ff.getCanonicalPath());
        FileFilter filter = new FileFilter() {
            public boolean accept(File pathname) {
                String name = pathname.getName();
                System.out.println("过滤：" + name);
                return name.startsWith("s");
            }
        };
        File[] subs = ff.listFiles(filter);
        //3.打印子项下所有名字
        for (int i = 0; i < subs.length; i++) {//i下标，从0开始
            System.out.println("查找到的：" + subs[i]);
        }
    }
}

